package com.ph.demo.io;

import java.io.*;

/**
 * 1.创建源
 * 2.选择流
 * 3.操作
 * 4.释放资源
 */
public class StreamDemo2 {

    public static void main(String[] args)  {
        //创建源

        File file = new File("C:\\Users\\peng\\Desktop\\1.txt");
        InputStream is = null;
        try {
            //选择流
           is = new FileInputStream(file);
            //操作流 读取
           int temp;
            while ((temp=is.read())!=-1){
                System.out.println((char)temp);
            }

        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }finally {
            //释放资源
            if(is !=null){
                try {
                    is.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }

        }


    }
}
